load("dfHMR.RData")

options(scipen=999, digits=4)
library(lm.beta)
library(jtools)
library(sjPlot)
library(haven)
library(dplyr)
library(descr)
library(tidyverse)
library(huxtable)
library(officer)
library(jtools)
library(sandwich)
library(dotwhisker)
library(broom)
library(coefplot)
library(ggplot2)


model1 <- lm(MisinfoScore ~ Age_W1 + Female + Education_W1 + Ideology_W1 + Satisf_Democracy_W2 + Trust_Election_Results_W2 + InstitutionalTrust + MSM_W2 + Freq_SM_News_W2 + Freq_Msg_News_W2 + Join_PolGroup_W1 + Freq_AltNews_W2 + Belief_Placebo, data = dfHMR)
summary(model1)

model2 <-lm(MisinfoScore ~ Age_W1 + Female + Education_W1 + Ideology_W1 + Satisf_Democracy_W2 + Trust_Election_Results_W2 +Trust_Government_W2+ Trust_Congress_W2 + Trust_Justice_W2 + Trust_Army_W2 + Trust_PolParties_W2 + MSM_W2 + Freq_SM_News_W2 + Freq_Msg_News_W2 + Join_PolGroup_W1 + Freq_AltNews_W2 + Belief_Placebo, data = dfHMR)
summary(model2)

plot_model(model2, show.values = FALSE, show.p = TRUE, auto.label = FALSE, vline.color = "grey") +
  scale_x_discrete(labels=list(
    "Age_W1" = "Age",
    "Education_W1" = "Education",
    "Female" = "Female",
    "Ideology_W1" = "Right Wing Ideology",
    "Satisf_Democracy_W2" = "Satisfaction Democracy",
    "Trust_Election_Results_W2" =  "Trust in Election Results",
    "Trust_Government_W2" = "Trust in Government",
    "Trust_Congress_W2" = "Trust in Congress",
    "Trust_Justice_W2" = "Trust in Jusice",
    "Trust_Army_W2" = "Trust in Army",
    "Trust_PolParties_W2" = "Trust in Political Parties",
    "MSM_W2" = "Frequency of Traditional News Use",
    "Freq_SM_News_W2" = "Frequency of Social Media News Use",
    "Freq_Msg_News_W2" = "Frequency of Messaging App News Use",
    "Join_PolGroup_W1"= "Joined Political WhatsApp Group",
    "Freq_AltNews_W2" = "Frequency of Alternative News Use",
    "Belief_Placebo"="Belief in Placebo Misinformation")) + labs(title = "OLS model predicting beliefs in electoral misinformation", caption = "Note: Blue indicates positive coefficients, and red indicates negative coefficients. 
                                                                 Overlap with the grey line indicate non-significant coefficients.", subtitle = "Unstandardized coefficients presented with 95% confidence intervals." ) + theme_apa()
